﻿//-----------------------------------------------------------------------
// <copyright file="IUnitOfWork.cs" company="WpfDevelopment.com">
//     Copyright WpfDevelopment.com. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace WpfDevelopment.Data
{
    using System;
    using WpfDevelopment.MVVM;

    /// <summary>
    /// The interface for the unit of work pattern
    /// </summary>
    public interface IUnitOfWork : IDisposable
    {
        /// <summary>
        /// Gets the context in which objects are persisted, should probaly not be used.
        /// </summary>
        /// <value>The context.</value>
        object Context { get; }

        /// <summary>
        /// Adds the specified entity.
        /// </summary>
        /// <typeparam name="T">The type of entity to persist</typeparam>
        /// <param name="entity">The entity.</param>
        void Add<T>(T entity) where T : ModelBase;

        /// <summary>
        /// Updates the specified entity.
        /// </summary>
        /// <typeparam name="T">The type of entity to persist</typeparam>
        /// <param name="entity">The entity.</param>
        void Update<T>(T entity) where T : ModelBase;

        /// <summary>
        /// Deletes the specified entity.
        /// </summary>
        /// <typeparam name="T">The type of entity to persist</typeparam>
        /// <param name="entity">The entity.</param>
        void Delete<T>(T entity) where T : ModelBase;

        /// <summary>
        /// Begins the transaction.
        /// </summary>
        void BeginTransaction();

        /// <summary>
        /// Commits the transaction.
        /// </summary>
        void CommitTransaction();

        /// <summary>
        /// Rollbacks the transaction.
        /// </summary>
        void RollbackTransaction();
    }
}
